package cn.devzyh.oms.coms.flow.service.impl;

import cn.devzyh.oms.common.core.constant.CommonConstants;
import cn.devzyh.oms.coms.api.flow.entity.Flow;
import cn.devzyh.oms.coms.flow.mapper.FlowMapper;
import cn.devzyh.oms.coms.flow.service.FlowService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class FlowServiceImpl extends ServiceImpl<FlowMapper, Flow> implements FlowService {

	@Override
	public void changeStatus(Long flowId, boolean enabled) {
		LambdaUpdateWrapper<Flow> wrapper = Wrappers.lambdaUpdate();
		wrapper.set(Flow::getStatus, enabled ? CommonConstants.YES : CommonConstants.NO);
		wrapper.eq(Flow::getId, flowId);
		update(wrapper);
	}

}